package program.Condition;

import program.SExpression;
import roborally.Robot;

/**
 * A class representing an ENERGY AT LEAST
 *  condition.
 * 
 * @author Jef Keijers/Bachelor of Science: Informatics
 * @version 1.0
 */
public class EnergyAtLeast extends Condition {
	/**
	 * This constructor instantiate a new EnergyAtLeast object with a given energy.	
	 * @param energy
	 */
	public EnergyAtLeast(String energy) {
		this.energy=Integer.valueOf(energy).intValue();
	}
	
	/**
	 * Instance variable of the energy from a condition.
	 */
	private int energy;
	
	/**
	 * This method returns true if the robots current energy level is higher or equal to the instance variable energy,
	 * otherwise it returns false.
	 */
	@Override
	public boolean execute(Robot robot) {
		if (robot.getEnergy().getValue()>=energy)
			return true;
		return false;
	}

	/**
	 * This method returns the SExpression representation of energy-at-least.
	 */
	@Override
	public SExpression toSExpression() {
		return this.makeSingletonSExpressionList("energy-at-least");
	}
}
